package com.sn.system.tangs.tag;

import java.io.Writer;

import org.apache.struts2.components.Component;

import com.opensymphony.xwork2.util.ValueStack;

public class Column extends Component{
	/** 列値の名 */
	private String property;
	/** 列タイトル名 */
	private String title;

	/** リンクＵＲＬ */
	private String href;

	/** リンクパラメータの名 */
	private String paramId;

	/** リンクパラメータの列値の名 */
	private String paramProperty;

	/** 列のタイプ */
	private String type;

	/** radio、checkBoxの名 */
	private String name;

	/** radio、checkBoxの列値の名 */
	private String value;

	/** 列値フォーマット */
	private String format;


    /** CSSのClass */
    private String cssClass;

    /** 列幅 */
    private String width;

    /** 列のalign */
    private String align;

	public String getCssClass() {
		return cssClass;
	}

	public void setCssClass(String cssClass) {
		this.cssClass = cssClass;
	}

	public String getWidth() {
		return width;
	}

	public void setWidth(String width) {
		this.width = width;
	}

	public String getAlign() {
		return align;
	}

	public void setAlign(String align) {
		this.align = align;
	}

	public String getFormat() {
		return format;
	}

	public Column(ValueStack stack) {
		super(stack);
	}

	/**
     * タグ開始
     */
	public boolean start(Writer writer) {
		boolean result = super.start(writer);
		setParam();
		return result;
	}

	/**
	* パラメータを設定する
	*/
	private void setParam() {
		String proplist=(String)this.getStack().pop();
		String titlist=(String)this.getStack().pop();
		String hreflist=(String)this.getStack().pop();
		String paramIdlist=(String)this.getStack().pop();
		String paramPropertylist=(String)this.getStack().pop();
		String typelist=(String)this.getStack().pop();
		String namelist=(String)this.getStack().pop();
		String valuelist=(String)this.getStack().pop();
		String formatlist=(String)this.getStack().pop();

		String cssClasslist=(String)this.getStack().pop();
		String widthlist=(String)this.getStack().pop();
		String alignlist=(String)this.getStack().pop();

		if(title==null)title=property;
		cssClass = cssClass==null?"":"class='"+cssClass+"' ";
		width = width==null?"":"width='"+width+"' ";
		align = align==null?"":"align='"+align+"' ";
		if(proplist==""){

			this.getStack().push(align);
			this.getStack().push(width);
			this.getStack().push(cssClass);

			this.getStack().push(format);
			this.getStack().push(value);
			this.getStack().push(name);
			this.getStack().push(type);
			this.getStack().push(paramProperty);
			this.getStack().push(paramId);
			this.getStack().push(href);
			this.getStack().push(title);
			this.getStack().push(property);
		}else {

			this.getStack().push(alignlist+","+align);
			this.getStack().push(widthlist+","+width);
			this.getStack().push(cssClasslist+","+cssClass);

			this.getStack().push(formatlist+","+format);
			this.getStack().push(valuelist+","+value);
			this.getStack().push(namelist+","+name);
			this.getStack().push(typelist+","+type);
			this.getStack().push(paramPropertylist+","+paramProperty);
			this.getStack().push(paramIdlist+","+paramId);
			this.getStack().push(hreflist+","+href);
			this.getStack().push(titlist+","+title);
			this.getStack().push(proplist+","+property);
		}
	}

		public String getProperty() {
			return property;
		}


		public void setProperty(String property) {
			this.property = property;
		}


		public String getTitle() {
			return title;
		}


		public void setTitle(String title) {
			this.title = title;
		}

	public String getHref() {
		return href;
	}


	public void setHref(String href) {
		this.href = href;
	}


	public String getParamId() {
		return paramId;
	}


	public void setParamId(String paramId) {
		this.paramId = paramId;
	}


	public String getParamProperty() {
		return paramProperty;
	}


	public void setParamProperty(String paramProperty) {
		this.paramProperty = paramProperty;
	}


	public String getType() {
		return type;
	}


	public void setType(String type) {
		this.type = type;
	}


	public String getName() {
		return name;
	}


	public void setName(String name) {
		this.name = name;
	}


	public String getValue() {
		return value;
	}


	public void setValue(String value) {
		this.value = value;
	}

	public void setFormat(String format) {
		this.format = format;
	}
}
